package BookManagement.operation;

import BookManagement.book.Book;
import BookManagement.book.Bookshelf;

import java.util.Scanner;


public class FindBook implements IBusinessOperation{
    @Override
    public void work(Bookshelf bookshelf) {
        System.out.println("查找图书：请输入要查找的书名");
        String name = "";
        Scanner scan = new Scanner(System.in);
        name = scan.nextLine();

        //先获取当前书架中有多少书籍
        int number = bookshelf.book_umber;
        //遍历查找
        int i = 0;
        for(; i<number; i++){
            if(name.equals(bookshelf.books[i].getName())){
                System.out.println("查找信息如下：");
                System.out.println(bookshelf.books[i]);
                break;
            }
        }
        if(i >= number){
            System.out.println("没查找到对应的书籍！");
        }
        else {
            System.out.println("查找成功！");
        }
    }
}
